# note --------------------------------------------------------------------

# this figure is based on data from the manifesto project
# the complete dataset (version 2020b) is available at https://manifesto-project.wzb.eu/

# import the pp dataset and plot the figure -------------------------------

figure_s1b <- read.csv("datasets/data_pp.csv") %>%
  filter(dataset == "marpor") %>%
  mutate(party = factor(party, levels = c("akp", "chp", "mhp", "hdp"),
                        labels = c("AKP", "CHP", "MHP", "HDP"))) %>%
  #pivot_wider(names_from = date, values_from = value) %>%
  ggplot(aes(x = date, y = value, group = party)) +
  geom_line(size = 1.2) + 
  geom_point(size = 2) +
  geom_text(aes(label = if_else(date == "2015_nov", as.character(party), "")),
            hjust = -0.4, vjust = 0.3, size = 4) +
  theme_light() +
  theme(axis.line = element_line(colour = "black", size = 0.25),
        panel.grid.major = element_line(colour = "grey95", size = 0.25),
        panel.grid.minor = element_line(colour = "grey95", size = 0.125),
        panel.border = element_rect(fill = NA, colour = "grey95", 
                                      size = 0.25),
        axis.text = element_text(size = 14), 
        axis.title = element_text(size = 14),
        legend.position = "none") +
  labs(x = NULL, y = "RILE scores in 2015\n") +
  scale_x_discrete(breaks = c("2015_jun", "2015_nov"),
                   labels = c("June\n2015", "November\n2015"))

# display the figure ------------------------------------------------------

print(figure_s1b)

# save the figure ---------------------------------------------------------

ggsave(plot = figure_s1b, filename = "figures/figure_s1b.pdf", dpi = 1000,
       width = 8.5, height = 6, units = "in")